#include "base/WrapperVtkmCont.h"
#include "base/WrapperVtkmTypes.h"
#include <petsc.h>

class PetscVector
{
public:
	PetscVector(Id m)
	{
		static_assert(std::is_same<PetscScalar, double>::value);
		init_from_vec(m);
	}
	void init_from_array(Id m)
	{
		arr.Allocate(m);
		//arr.GetBuffers()[0].ReadPointerHost();
	}

	void init_from_vec(Id m)
	{
		VecCreate(PETSC_COMM_WORLD, &v);
		VecSetSizes(v, PETSC_DECIDE, m);
		VecSetFromOptions(v);

		PetscScalar* pts;
		VecGetArray(v, &pts);
		arr = vtkm::cont::make_ArrayHandle(pts, m);
	}

	~PetscVector();

private:
	Vec v;
	PetscScalar length;
	ArrayHandle<PetscScalar> arr;
};

